Security News
Combatting Alert Fatigue by Prioritizing Malicious Intent
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
object-to-spawn-args
Advanced tools
Converts an options object to an array suitable for passing to child_process.spawn()
.
Single letter object properties (e.g. c: 'red'
) convert to short-option args (e.g. -c red
). Longer object properties (e.g. colour: 'red'
) convert to long-option args (e.g. --colour red
). Object property values equalling true
convert to flags (e.g. -l
).
Simple usage:
> const objectToSpawnArgs = require('object-to-spawn-args')
> const spawnArgs = objectToSpawnArgs({
l: true,
c: 'red',
name: 'pete',
tramp: true
})
> console.log(spawnArgs)
[ '-l', '-c', 'red', '--name', 'pete', '--tramp' ]
Alternatively, convert to --object=value
notation.
> const options = {
l: true,
c: 'red',
name: 'pete',
tramp: true
}
> const spawnArgs = objectToSpawnArgs(options, { optionEqualsValue: true })
> console.log(spawnArgs)
[ '-l', '-c=red', '--name=pete', '--tramp' ]
Typical real-life example.
const objectToSpawnArgs = require('object-to-spawn-args')
const spawn = require('child_process').spawn
const options = {
l: true,
a: true
}
spawn('ls', objectToSpawnArgs(options), { stdio: 'inherit' })
$ npm install object-to-spawn-args
© 2014-21 Lloyd Brookes <75pound@gmail.com>.
FAQs
Converts an object to a child_process.spawn args array
The npm package object-to-spawn-args receives a total of 125,306 weekly downloads. As such, object-to-spawn-args popularity was classified as popular.
We found that object-to-spawn-args demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.